<?php $this->load->view('layout/adminHeader'); ?>
    
    <div id="mainContent" class="floatFix">
    	<?php $this->load->view('layout/adminToursSubmenu'); ?>
        
        <div class="lCol">
           	
            <?php $this->load->view('layout/flashdata'); ?>
            
            <h2>Edit Tour Type</h2>
            
            <?php echo validation_errors(); ?>
            
            <form action="<?php echo site_url("tourtypes/update/" . $tour['id']); ?>" method="post">
                <ul class="formContainer">
                    <li class="floatFix">
                        <label>Tour Name</label>
                        <input type="text" name="tour_name" id="tour_name" value="<?php echo set_value('tour_name', $tour['tour_name']); ?>" />
                    </li>
                    
                    <li class="floatFix">
                        <label>Tour Code</label>
                        <input type="text" name="tour_code" id="tour_code" value="<?php echo set_value('tour_code', $tour['tour_code']); ?>" />
                    </li>
                    
                    <li class="floatFix">
                        <label>Number of nights</label>
                        <input type="text" name="tour_nights" id="tour_nights" value="<?php echo set_value('tour_nights', $tour['tour_nights']); ?>" />
                    </li>
                    
                    <li class="floatFix">
                        <label>Default Price</label>
                        <input type="text" name="default_price" id="default_price" value="<?php echo set_value('default_price', number_format($tour['default_price'], 2, '.', '')); ?>" />
                    </li>
                    
                    <li><h3>Default Itinerary</h3></li>
                    <?php
						for ($i = 0; $i < $tour['tour_nights']; $i++)
						{
							$d = "<li class=\"floatFix\">\n";
							$d .= "\t<label>Night " . ($i + 1) . "</label>\n";
                        	if ($i < count($itinerary))
							{
								$selected_id = $itinerary[$i]['hostel_id'];
							} else
							{
								$selected_id = '';	
							}
							
							if (isset($_POST['hostel_names']))
							{
								if (isset($_POST['hostel_names'][$i + 1]))
								{
									$selected_id = $_POST['hostel_names'][$i + 1]; 	
								}
							}
							
							if (count($itinerary) > 0 && $i < count($itinerary))
							{
								$d .= "\t" . hostel_dropdown($i + 1, $selected_id) . "\n";
								
							} else
							{
								$d .= "\t" . hostel_dropdown($i + 1) . "\n";
							}
												
							$d .= "</li>";
							
							echo $d;
						}
					?>
                                 
                    <li class="floatFix">
                        <input type="submit" class="submitButton" value="Save Changes" />
                    </li>
                </ul>
            </form>
            
                 
        </div>
        
        <div class="rCol">
        	<h2>Sidebar</h2>
        </div>
        
        
    	
    </div>
    
<?php $this->load->view('layout/adminFooter'); ?>